  	//压缩图片
	function wxinimageComporess (Originalfile,i,quality) { 
		var sourceImageid=imageArray[i];
	    var sourceImage = new Image();
	    sourceImage.crossOrigin = "anonymous";
	    sourceImage.src=Originalfile; 
	    sourceImage.id=sourceImageid;
	    sourceImage.onload=(function(sourceImage) {
	    	var old_size=dataURL2Blob(sourceImage.src);
	    	
		    var canvas = document.createElement("canvas");
		    var context = canvas.getContext('2d')	
		    if (!isCanvasBlank(canvas)) {
		      context.clearRect(0, 0, canvas.width, canvas.height)
		    }
		    canvas.width = sourceImage.width;
		    canvas.height = sourceImage.height;
		    context.drawImage(sourceImage, 0, 0)	    
		    var mimeType ='image/gif';
		   var compressedImageDataURL = canvas.toDataURL(mimeType, quality / 100);
		  	var new_size=dataURL2Blob(compressedImageDataURL);		  	
		    var data=new Object;
		    if(new_size.size>old_size.size){
		    	 data.base64url=compressedImageDataURL;
		    	  data.compress=true;
		    }else{
		     	data.base64url=sourceImage.src;	
		        data.compress=false;
		    }
		    console.log(sourceImage)
		    console.log('图片原来大小：'+old_size.size+ '图片的宽高：'+sourceImage.width  +'x'+sourceImage.height+ (data.compress==true?'压缩':'不压缩'))
		    console.log('新图片大小：'+new_size.size+ '图片的宽高：'+canvas.width  +'x'+ canvas.height+ (data.compress==true?'压缩':'不压缩'))
		    
		    data.name=getCurrenTemptime('');
		    data.width=sourceImage.width;
		    data.height=sourceImage.height;
		   wexingetchange(data);
	   })(sourceImage);
	}
	 
 
 
	
//单张上传图片
function wexingetchange(data,fn){
			var name= data.name;		
			$.ajax({
				type: "POST",
				url: baseUrl+"other/image/upload_image",
				data: {image_data:data.base64url,user_id:user_id,source:2,work_id:workid},
				dataType: 'json',				
				beforeSend: function(XMLHttpRequest){
				var li='<li class="weui-uploader__file weui-uploader__file_status" name="'+name+'">'+
					               	'<div class="upload_img" style="background-image:url('+data.base64url+')" src="'+data.base64url+'"></div>'+
					               	'<div class="weui-uploader__file-content la-ball-beat la-sm"><i></i><i></i><i></i> </div>'+
				              	 '</li>';
				                
				$("#uploaderFiles").prepend(li);
				var imgitem=$('#uploaderFiles li[name="'+name+'"]').find('img');
				var imgw=imgitem.width();
				var imgh=imgitem.height();
				var w_sacle=imgw/imgh;
				var box_h=$(".weui-uploader__input-box").height();			
				var strw=w_sacle>1?'height:'+box_h+'px; width:'+w_sacle*box_h+'px; margin-left:'+(w_sacle*box_h-box_h)/2*-1+'px;':'width:'+box_h+'px; height:'+box_h/w_sacle+'px; margin-top:'+(box_h/w_sacle-box_h)/2*-1+'px;';
				imgitem.attr('style',strw);
				console.log('宽'+imgw,'高'+imgh)
				},
				success: function(result) {
					if(result.code!=200){ 
					var item=$('#uploaderFiles li[name="'+name+'"]')
					item.find(".la-ball-beat").remove();
					item.append('<div class="weui-uploader__file-content up_refresh base64_refresh"> <i class="fa fa-refresh fa-lg"></i></div><div class="up_refreshtxt"><span>上传失败</span><span>重新上传</span> </div>');
					
					 dialogshow("错误",result.description);
						
					}else{
						var item=$('#uploaderFiles li[name="'+name+'"]');
						item.addClass("upload_sucess");
						item.find(".la-ball-beat").remove();					
						if(result.data.quality!=0){//照片的一边小于900    照片像素过低可能导致，图片模糊   0=正常；1=比例不符合；2=像素不符合
							item.append('<div class="upload_i_worn"><i class="weui-icon-warn"></i> </div>');
							console.log('quality' +result.data.quality);
						}
						//item.find(".upload_img img").attr("src",result.data.image_url);
						//item.find(".upload_img img").attr("image_id",result.data.id);
						item.append('<div class="delimportimg"><i class="fa fa-close fa-fw"></i></div>');	
						item.removeClass("weui-uploader__file_status");
						$(".upload_num").text($(".upload_sucess").length);
						$(".uploadoper").find("a").eq(1).show().siblings("a").hide();
						$('#uploaderInput').attr("large_image_num",$('#uploaderInput').attr("image_num")-parseInt($(".upload_num").text()));
						
					}
					fn();
				},
				error: function(XMLHttpRequest, textStatus, errorThrown) {
					var item=$('#uploaderFiles li[name="'+name+'"]')
					item.find(".la-ball-beat").remove();
					item.append('<div class="weui-uploader__file-content up_refresh base64_refresh"> <i class="fa fa-refresh fa-lg"></i></div><div class="up_refreshtxt"><span>上传失败</span><span>重新上传</span> </div>');
					fn();
				}
			
			});
	
	
}	


